package com.jy.rhin.support.polymorphism.convertor;

import cn.org.chiss.rhin._2015.document.management.DocumentStoredQueryResponse;
import com.jy.rhin.sdk.dto.document.DocumentEntryDto;
import com.jy.rhin.sdk.dto.document.DocumentResultDto;
import com.jy.rhin.sdk.dto.document.query.GetDocumentsDto;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author dhl
 * @date 2022/6/22
 * @Description
 */
@Service("getDocuments")
public class DocumentQueryHandler4GetDocuments extends AbstractDocumentQueryHandler<GetDocumentsDto, DocumentEntryDto>{
    @Override
    GetDocumentsDto convertReq(Map<String, List<String>> dtoValueMap) {
        GetDocumentsDto dto = new GetDocumentsDto();
        dto.setIdList(QueryValueUtils.getListValue("$DocumentEntryUUID", dtoValueMap));
        dto.setUniqueIdList(QueryValueUtils.getListValue("$DocumentEntryUniqueId", dtoValueMap));
        dto.setHomeCommunityId(QueryValueUtils.getStringValue("$HomeCommunityId", dtoValueMap));
        return dto;
    }

    @Override
    DocumentResultDto<DocumentEntryDto> query(GetDocumentsDto dto) {
        return documentSubmissionQueryHandler.getDocuments(dto);
    }

    @Override
    DocumentStoredQueryResponse convertResp(List<DocumentEntryDto> resultList, List<String> jsonTextList) {
        return entryConvert(resultList, jsonTextList);
    }
}
